package frame.util;

import java.nio.ByteBuffer;

// 处理ByteBuffer的工具类
public class ByteBufferUtil {

    // 返回其中的数据并清空该缓存
    public static byte[] readAndClear(ByteBuffer buffer) {

        buffer.flip();

        byte[] frame = new byte[buffer.limit() - buffer.position()];

        buffer.get(frame).clear();

        return frame;
    }
}
